package
{
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.utils.Dictionary;
	
	import gameObject.Circle;
	import gameObject.Robot;
	
	import net.P2p;
	
	
	/**
	 * 
	 * 现在角色与建筑物，玩家与玩家间的碰撞处理是在这里计算
	 * 
	 */	
	public class CollisionWorld extends Sprite
	{
		public static var collObjs:Dictionary;
		public static var collisionMap:Bitmap;
		
		public static var hitStartX:Number;
		public static var hitStartY:Number;
		public static var mapScaleX:Number;
		public static var mapScaleY:Number;
		
		public static function roleHitTestBuilding(robot:Robot):Boolean
		{
			var myHitArea:Circle = robot.hitArea;
			var hitTest:Boolean = myHitArea.bitmapData.hitTest(new Point(myHitArea.x, myHitArea.y), 50, collisionMap.bitmapData,new Point(0,0),50);
			
			if(!hitTest)
			{
				for each(var rob:Robot in collObjs)
				{
					if(rob.uid!=robot.uid)
					{
						var hitArea:Circle = collObjs[rob.uid].hitArea;
						hitTest = myHitArea.bitmapData.hitTest(new Point(myHitArea.x, myHitArea.y), 50, hitArea.bitmapData,new Point(hitArea.x,hitArea.y),50);
						
						if(hitTest)break ;
					}
				}
			}
			
			return hitTest;
		}
		
	}
}